Skip to content

modularize the config module bootstrap #141272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Shourya742
Copy link
Contributor

@Shourya742 Shourya742 commented May 20, 2025

Currently, our config module is quite large over 3,000 lines, and handles a wide range of responsibilities. This PR aims to break it down into smaller, more focused submodules to improve readability and maintainability:

  • toml: Introduces a dedicated toml submodule within the config module. Its sole purpose is to define configuration-related structs along with their corresponding deserialization logic. It also contains the parse_inner method, which serves as the central function for extracting relevant information from the TOML structs and constructing the final configuration.

  • rust, dist, install, llvm, build, gcc, and others: Each of these modules contains TOML subsections specific to their domain, along with the logic necessary to convert them into parts of the final configuration struct.

  • config/mod.rs: Contains shared types and enums used across multiple TOML subsections.

  • config/config.rs: Houses the logic that integrates all the TOML subsections into the complete configuration struct.

r? @Kobzol

@rustbot
Copy link
Collaborator

rustbot commented May 20, 2025

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 20, 2025
@rustbot

This comment has been minimized.

@Shourya742 Shourya742 force-pushed the 2025-05-18-modularize-config-module branch from 6a1e868 to b8374d6 Compare May 20, 2025 03:17
@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the general direction of this. Could you perhaps split the changes into multiple commits though? It would be easier to review. Thank you :)

@Shourya742 Shourya742 force-pushed the 2025-05-18-modularize-config-module branch from b8374d6 to ad21211 Compare May 21, 2025 17:19
@Kobzol
Copy link
Contributor

Kobzol commented May 22, 2025

Kind of crazy just how much code is there in config definition and parsing. The changes LGTM, but since this is a large-ish change, I'd like to hear also from other members of t-bootstrap if they are OK with it. CC @onur-ozkan @jieyouxu.

@jieyouxu jieyouxu self-assigned this May 24, 2025
@onur-ozkan
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 24, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@jieyouxu
Copy link
Member

cc @clubby789

@Shourya742
Copy link
Contributor Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 24, 2025
@jieyouxu jieyouxu removed their assignment May 26, 2025
@jieyouxu
Copy link
Member

Vibes-wise, organization seems fine to me.

@onur-ozkan
Copy link
Member

onur-ozkan commented May 28, 2025

I still have this concern (also see this as an additional ref). With the current approach, adding new things will always be unclear for some people. Even now, for example, we have parsing.rs and types.rs modules but some parsing logic has leaked into other modules and some types have leaked to some other modules as well.

What I would suggest instead is organizing the modules based on the configuration field. For example, mod.rs could represent the root level of the configuration and the rest could be split into the sub fields like rust.rs for [rust], llvm.rs for [llvm], target_specific.rs for things like [target.x86_64-unknown-linux-gnu], etc.

With this structure it would make it very explicit where things belong and anything that doesn't fit this rule can be easily caught during PR reviews.

@Shourya742 Shourya742 requested review from Kobzol and onur-ozkan May 29, 2025 12:42
@rust-log-analyzer

This comment has been minimized.

@Shourya742 Shourya742 force-pushed the 2025-05-18-modularize-config-module branch from 2dc25e6 to 877aa18 Compare May 29, 2025 12:53
@Shourya742 Shourya742 force-pushed the 2025-05-18-modularize-config-module branch from 1ec9ad3 to 6ec7ec9 Compare June 3, 2025 08:26
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you so much for looking into this!

@onur-ozkan
Copy link
Member

Do you have any concerns on the current state of this PR? I don't want to r+ without your approval since you were the main reviewer. @Kobzol

@Kobzol
Copy link
Contributor

Kobzol commented Jun 4, 2025

No, I'm good. Thank you, great work!

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 4, 2025

📌 Commit 6ec7ec9 has been approved by Kobzol

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 4, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 5, 2025
…onfig-module, r=Kobzol

modularize the config module bootstrap

Currently, our `config` module is quite large over 3,000 lines, and handles a wide range of responsibilities. This PR aims to break it down into smaller, more focused submodules to improve readability and maintainability:

* **`toml`**: Introduces a dedicated `toml` submodule within the `config` module. Its sole purpose is to define configuration-related structs along with their corresponding deserialization logic. It also contains the `parse_inner` method, which serves as the central function for extracting relevant information from the TOML structs and constructing the final configuration.

* **`rust`, `dist`, `install`, `llvm`, `build`, `gcc`, and others**: Each of these modules contains TOML subsections specific to their domain, along with the logic necessary to convert them into parts of the final configuration struct.

* **`config/mod.rs`**: Contains shared types and enums used across multiple TOML subsections.

* **`config/config.rs`**: Houses the logic that integrates all the TOML subsections into the complete configuration struct.

r? `@kobzol`
bors added a commit that referenced this pull request Jun 5, 2025
Rollup of 8 pull requests

Successful merges:

 - #140638 (UnsafePinned: also include the effects of UnsafeCell)
 - #141272 (modularize the config module bootstrap)
 - #141777 (Do not run PGO/BOLT in x64 Linux alt builds)
 - #141870 (Fix broken link to rustc_type_ir module in serialization docs)
 - #141938 (update rust offload bootstrap)
 - #141962 (rustc-dev-guide subtree update)
 - #141965 (`tests/ui`: A New Order [3/N])
 - #141970 (implement new `x` flag: `--skip-std-check-if-no-download-rustc`)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

@bors r-
#142059 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 5, 2025
@Shourya742 Shourya742 force-pushed the 2025-05-18-modularize-config-module branch from 6ec7ec9 to 3667dbd Compare June 5, 2025 10:57
@Kobzol
Copy link
Contributor

Kobzol commented Jun 5, 2025

Hmm, we should probably run x doc bootstrap in PR CI, this is not the first time this has bitten us, and we will hopefully document more and more things in bootstrap now.

@bors r+ rollup=iffy

@bors
Copy link
Collaborator

bors commented Jun 5, 2025

📌 Commit 3667dbd has been approved by Kobzol

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 5, 2025
@bors
Copy link
Collaborator

bors commented Jun 6, 2025

⌛ Testing commit 3667dbd with merge d00435f...

@bors
Copy link
Collaborator

bors commented Jun 6, 2025

☀️ Test successful - checks-actions
Approved by: Kobzol
Pushing d00435f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 6, 2025
@bors bors merged commit d00435f into rust-lang:master Jun 6, 2025
11 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 6, 2025
Copy link
Contributor

github-actions bot commented Jun 6, 2025

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing cf42371 (parent) -> d00435f (this PR)

Test differences

No test diffs found

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard d00435f223dc3a88d8c5f472b10ba948b7959cc6 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-apple-various: 6377.8s -> 8058.3s (26.4%)
  2. aarch64-apple: 4692.3s -> 4026.0s (-14.2%)
  3. x86_64-gnu: 6636.4s -> 7492.5s (12.9%)
  4. x86_64-rust-for-linux: 2548.0s -> 2859.1s (12.2%)
  5. armhf-gnu: 4482.8s -> 5028.1s (12.2%)
  6. i686-gnu-1: 7149.2s -> 8018.6s (12.2%)
  7. i686-gnu-nopt-1: 7074.8s -> 7919.2s (11.9%)
  8. i686-gnu-2: 5285.6s -> 5902.9s (11.7%)
  9. x86_64-gnu-llvm-20-1: 3226.9s -> 3587.3s (11.2%)
  10. mingw-check-2: 1836.4s -> 2040.4s (11.1%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants